package com.jlcloud.core.context.config;

import com.jlcloud.core.context.JlCloudHttpHeadersGetter;
import com.jlcloud.core.context.props.JlCloudContextProperties;
import com.jlcloud.core.context.listener.JlCloudServletRequestListener;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.web.servlet.ServletListenerRegistrationBean;
import org.springframework.context.annotation.Bean;

/**
 * Servlet 监听器自动配置
 *
 * @author By: JlCloud <br>
 * @Package: com.jlcloud <br>
 * @CreateTime: 2024-12-03 21:45 <br>
 * @Copyright: 2021 www.jilianjituan.com Inc. All rights reserved. <br>
 * @Caution 注意：本内容仅限于冀联人力集团内部传阅，禁止外泄以及用于其他的商业目的 <br>
 */
@AutoConfiguration
@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET)
public class JlCloudServletListenerConfiguration {

	@Bean
	public ServletListenerRegistrationBean<?> registerCustomListener(JlCloudContextProperties properties,
                                                                     JlCloudHttpHeadersGetter httpHeadersGetter) {
		return new ServletListenerRegistrationBean<>(new JlCloudServletRequestListener(properties, httpHeadersGetter));
	}

}
